#ifndef BitOps_H_GUARD
#define BitOps_H_GUARD

//USE: check a bit
// example bit_get(foo, BIT(3)) to check bit number 3
#define bit_get(p,m) ((p) & (m)) 

//USE: set a bit 
//example bit_set(foo, 0x01)
//example bit_set(foo, BIT(5)) - set bit number 5
#define bit_set(p,m) ((p) |= (m)) 

//Use: clear a bit
//example bit_clear(foo, 0x40) - clear bit 6 with a bit mask
//example bit_clear(bar, BIT(0)) - clear bit 0
#define bit_clear(p,m) ((p) &= ~(m)) 

//USE: Flip a bit
//example bit_flip(foo, BIT(0)) - flip bit 0
#define bit_flip(p,m) ((p) ^= (m)) 

//USE: set or clear a bit based on another bit
//example bit_write(bit_get(foo, BIT(4)), bar, BIT(0)) - clear or set bit 
// 														 0 based on bit 4
#define bit_write(c,p,m) (c ? bit_set(p,m) : bit_clear(p,m)) 

#define BIT(x) (0x01 << (x)) 

#define LONGBIT(x) ((unsigned long)0x00000001 << (x))

#endif
